<?php
/**
 * 微教育模块
 *
 * @author 高贵血迹
 */
        global $_W, $_GPC;
        $weid = $this->weid;
        $from_user = $this->_fromuser;
		$schoolid = intval($_GPC['schoolid']);
		$openid = $_W['openid'];
        
        //查询是否用户登录		
		$userid = pdo_fetch("SELECT * FROM " . tablename($this->table_user) . " where :schoolid = schoolid And :weid = weid And :openid = openid And :sid = sid", array(':weid' => $weid, ':schoolid' => $schoolid, ':openid' => $openid, ':sid' => 0), 'id');	
		$it = pdo_fetch("SELECT * FROM " . tablename($this->table_user) . " where weid = :weid AND id=:id ORDER BY id DESC", array(':weid' => $weid, ':id' => $userid['id']));	
		$school = pdo_fetch("SELECT * FROM " . tablename($this->table_index) . " where weid = :weid AND id=:id ORDER BY ssort DESC", array(':weid' => $weid, ':id' => $schoolid));
		if ($_GPC['getalist']) {
			$pageSize = intval($_GPC['pageSize']);
			$nowPage = intval($_GPC['nowpage']);
			$item_per_page = empty($_GPC['pageSize']) ? 10 : intval($_GPC['pageSize']);
			$page_number = max(1, intval($_GPC['nowpage']));
			if(!is_numeric($page_number)){
	   			header('HTTP/1.1 500 Invalid page number!');  
	    		exit();  
			}
			$position = ($page_number-1) * $item_per_page;	
		    $leave1 = pdo_fetchall("SELECT id,bj_id,km_id,title,tname,createtime FROM " . tablename($this->table_notice) . " where weid = '{$weid}' And schoolid = '{$schoolid}' And tid = '{$it['tid']}' And type = 3  ORDER BY createtime DESC LIMIT " . $position . ',' . $item_per_page );
			
			foreach($leave1 as $key =>$row){
				$banji = pdo_fetch("SELECT sname FROM " . tablename($this->table_classify) . " where sid = :sid And schoolid = :schoolid ", array(':schoolid' => $schoolid,':sid' => $row['bj_id']));
				$leave1[$key]['banji'] = $banji['sname'];
				$leave1[$key]['name'] = $row['tname']."老师";
				$kemu = pdo_fetch("SELECT sname FROM " . tablename($this->table_classify) . " where sid = :sid And schoolid = :schoolid ", array(':schoolid' => $schoolid,':sid' => $row['km_id']));
				$list2 = pdo_fetchall("SELECT id FROM ".tablename($this->table_record)." WHERE weid = '{$weid}' And schoolid = '{$schoolid}' And noticeid = '{$row['id']}' And readtime > 5000 ");
				$leave1[$key]['ydrs'] = "已读".count($list2)."人";	
				$leave1[$key]['kemu'] = $kemu['sname'];
				$leave1[$key]['time'] = date('m-d', $row['createtime']);	
			}
			$datas = array(
			'ret' => array('code' => '200','msg' => 'success'),
			'data' => array(
						'dataList' => $leave1,
						'nowPage' => $nowPage,
							)
					);
					
			echo json_encode($datas);
			exit;
		}				        		
        if(!empty($userid['id'])){ 						
			include $this->template(''.$school['style3'].'/zuoyelist');
        }else{
			include $this->template('bangding');
        }        
?>